home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / doPerformLoft.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  4.5 KB  |  173 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  Mar 14, 1997
  22. //
  23. //
  24. //  Description:
  25. //      This script performs loft action on the selection list.
  26. //
  27.  
  28.  
  29. proc addOneToLoft( string $loft, int $index, string $curve, int $range )
  30. {
  31.     string $node[] = `duplicateCurve -rn $range -o false $curve`;
  32.     if( size($node) > 0 ) {
  33.         if( "nurbsCurve" == `nodeType $node[0]`) {
  34.             connectAttr ($curve + ".ws") ($loft + ".ic[" + $index + "]");
  35.         }
  36.         else {
  37.             connectAttr ($node[0] + ".oc") ($loft + ".ic[" + $index + "]");
  38.         }
  39.     }
  40. }
  41.  
  42. proc int addToLoft( string $lofted, string $curves[], int $range )
  43. {
  44.     if( size($curves) < 1 ) return false;
  45.  
  46.     string $hst[] = `listHistory -gl true -pdo true -lf true -f false $lofted `;
  47.     int $i, $n = size($hst);
  48.     if( $n < 1 ) return false;
  49.  
  50.     string $hist[];
  51.  
  52.     // tokenize && append.
  53.     //
  54.     for( $i = 0 ; $i < $n ; $i++ ) {
  55.         string $tmp[] ;
  56.         tokenize( $hst[$i], "|", $tmp );
  57.         int $l = size($tmp);
  58.         int $len = size($hist) ;
  59.         int $j ;
  60.         for( $j = 0 ; $j < $l ; $j++ ) {
  61.             $hist[$len+$j] = $tmp[$j] ;
  62.         }
  63.     }
  64.  
  65.     string $loft = "";
  66.  
  67.     // look for the first node which is of type "loft".
  68.     //
  69.     $n = size($hist) ;
  70.     for( $i=0; $i<$n; $i+=1 ) {
  71.         string $name = $hist[$i] ;
  72.         if( "loft" == `nodeType $name` ) {
  73.             $loft = $name;
  74.             break;
  75.         }
  76.     }
  77.  
  78.     if( "" == $loft ) return false;
  79.  
  80.     int $cntr = eval( "getAttr -s " + $loft + ".ic" );
  81.     $n = size($curves);
  82.     for( $i=0; $i<$n; $i+=1 ) {
  83.         addOneToLoft( $loft, $cntr, $curves[$i], $range );
  84.         $cntr += 1;
  85.     }
  86.  
  87.     return true;
  88. }
  89.  
  90. global proc doPerformLoft( string $version, string $args[] )
  91. {
  92.  
  93.     if( 8 != size($args)) {
  94.         error( "Incorrect number of arguments to doPerformLoft" );
  95.         return;
  96.     }
  97.  
  98.     int $history = $args[0];
  99.     int $uniform = $args[1];
  100.     int $autoReverse = $args[2];
  101.     int $close = $args[3];
  102.     int $degree = $args[4];
  103.     int $spans = $args[5];
  104.     int $range = $args[6];
  105.     int $polys = $args[7];
  106.  
  107.     // Get a list of each type of acceptable object type - 
  108.     // curves, and curves-on-surface.
  109.     //
  110.     global int $gSelectNurbsCurvesBit;
  111.     global int $gSelectIsoparmsBit;
  112.     global int $gSelectSurfaceEdgeBit;
  113.     global int $gSelectCurvesOnSurfacesBit;
  114.     global int $gSelectMeshEdge;
  115.  
  116.     global int $gSelectNurbsSurfacesBit;
  117.     global int $gSelectMeshesBit;
  118.  
  119.     string $curves[] = `filterExpand -ex true -sm $gSelectMeshEdge -sm $gSelectNurbsCurvesBit -sm $gSelectIsoparmsBit -sm $gSelectSurfaceEdgeBit -sm $gSelectCurvesOnSurfacesBit`;
  120.     string $lofted[] = `filterExpand -ex true -sm $gSelectNurbsSurfacesBit -sm $gSelectMeshesBit`;
  121.  
  122.     int $added = false;
  123.     if( 1 == size($lofted) ) {
  124.         $added = addToLoft( $lofted[0], $curves, $range );
  125.         if( $added ) {
  126.             select -r $lofted[0];
  127.             return;
  128.         }
  129.     }
  130.  
  131.     // Execute loft on all active curves.
  132.     //
  133.     int $i, $n;
  134.     $n = size($curves);
  135.     if( $n > 1 ) {
  136.         $cmd = "loft" + " -ch " + $history + 
  137.             " -u " + $uniform+
  138.             " -c " + $close + 
  139.             " -ar " + $autoReverse +
  140.             " -d " + $degree +
  141.             " -ss " + $spans +
  142.             " -rn " + $range +
  143.             " -po " + $polys +
  144.             " -rsn true";
  145.  
  146.         for( $i=0; $i<$n; $i+=1 ) {
  147.             $cmd = $cmd + " \"" + $curves[$i] + "\"";
  148.         }
  149.  
  150.         string $result[] = evalEcho($cmd);
  151.  
  152.         if( 0 == size($result) ) {
  153.             warning("Nothing was selected to loft.  You must select curves.");
  154.         }
  155.         else {
  156.             // Select all the results
  157.             //
  158.             select -cl;
  159.             int $len = size($result) ;
  160.             for( $i = 0 ; $i < $len ; $i++ ) {
  161.                 if( $i == 0 ) select -r $result[$i] ;
  162.                 else select -add $result[$i] ;
  163.             }
  164.         }
  165.     }
  166.     else {
  167.         if( !`optionVar -q modelWithToolLoft` ) {
  168.             error("Invalid selection.  Need at least two curves.");
  169.         }
  170.     }
  171. }
  172.  
  173.